package com.pet.controller;


import com.pet.dto.PetAddDTO;
import com.pet.dto.PetQueryDTO;
import com.pet.dto.PetUpdateDTO;
import com.pet.dto.Result;
import com.pet.entity.PetDO;
import com.pet.service.PetService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/pet")
public class PetController {
    @Resource
    private PetService petService;

    /**
     * 添加宠物
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody PetAddDTO dto){
        return petService.add(dto);
    }

    /**
     * 查询宠物列表
     * @param
     * @return
     */
    @PostMapping("/list")
    public Result list(@RequestBody PetQueryDTO dto){
        List<PetDO> petList = petService.queryList(dto);
        return Result.success(petList);
    }

    /**
     * 更新宠物
     * @param
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody PetUpdateDTO dto){
        return petService.updatePet(dto);
    }

    /**
     * 删除宠物
     * @param
     * @return
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody PetUpdateDTO dto){
        return petService.deletePet(dto);
    }
}